<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="format-detection" content="telephone=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <script src="/js/resize.js"></script>
    <% include baiduTJ.html %>
    <link rel="stylesheet" href="/css/myreset.min.css">
    <link rel="stylesheet" href="/css/animate.css">
    <link rel="stylesheet" href="/fightqccode/css/fightqccode.css">
    <title>壳牌劲霸 焕新有礼</title>
</head>
<body>

<div class="container">
    <div class="qccode"></div>
    <div class="word"></div>
</div>

<div class="sao animated infinite pulse"></div>

<script src="/js/zepto.1.1.6.min.js"></script>
<script src="/js/base.2.0.js"></script>
<script src="/js/jweixin-1.0.0.js"></script>
<script src="/js/weixin.js"></script>
<% include wxshare.html %>
<script>
    var qccode = null;
    var media_id = '<%= media_id %>';
    $(".sao").on("tap", function () {
        wx.scanQRCode({
            needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
            scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码，默认二者都有
            success: function (res) {
                qccode = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
                checkCode(function (data) {
                    if (data.errno) {
                        alert("验证未通过");
                    } else {
                        window.location.href = "/index/shell/fight/rolutte";
                    }
                });
            }
        });
    });

    var checkCode = function (cb) {
        if (!media_id) {
            return alert("请先上传图片");
        }
        $.ajax({
            url: "/index/shell/fight/checkcode",
            type: "POST",
            data: {
                acCode: qccode.split("?")[1].substr(1, 16),
                media_id: media_id
            },
            dataType: "json",
            success: function (data) {
                cb(data);
            },
            error: function () {
                alert("网络错误");
            }
        })
    }
</script>
</body>
</html>